package com.coderfans.datagithub.processservice.impl;

import com.coderfans.datagithub.processservice.IProcessService;
import com.coderfans.datagithub.processservice.SinglePageModel;

import java.lang.reflect.Field;
import java.util.Map;

/**
 * Created by ${fanchunshuai} on 2016-11-14.
 *
 * @version: V1.0
 * @Desc:  爬取github用户的首页如  https://github.com/zhangsan
 *          获取github该用户的基本信息
 * @Copyright (c) 2016 58到家-版权所有
 */
public class UserProcessService implements IProcessService{

    private Map<String,String > map;

    /**
     * 构造方法传入参数
     * 爬取的键-值(xpath)
     * @param xParamMap
     */
    public UserProcessService(Map<String,String> xParamMap){
        this.map = xParamMap;
    }

    @Override
    public Map<String, Object> processPage( String link, int threadNum,Class clazz) throws IllegalAccessException, InstantiationException, ClassNotFoundException {
        SinglePageModel pageModel = new SinglePageModel(map);
        if(threadNum<=0){
            return pageModel.runSpider(link,2);
        }else {
            return pageModel.runSpider(link,threadNum);
        }

    }



}
